import request from "@/utils/request";

import {
  Common,
  postCreateDocumentTreeForm,
  putUpdateDocumentTreeName,
  postUploadDocumentTreeFile,
} from "./type";

enum AllFilesApi {
  PostCreatDocumentTree = "/file/createDocumentTree",// 创建文件夹路径
  GetDocumentTree = "/file/getDocumentTree",// 查询文件夹关系接口
  PutUpdateDocumentTreeName = "/file/updateDocumentTreeName",// 修改文件夹名字和备注接口
  DeleteDocumentTree = "/file/deleteDocumentTree",// 删除文件夹接口
  DeleteFileById = "/file/deleteFileById",// 删除指定文件接口
  GetDocumentTreeFiles = "/file/getDocumentTreeFiles",// 查询文件夹包含文件接口
  PostUploadDocumentTreeFile = "/file/uploadDocumentTreeFile",// 指定文件夹上传文件接口
};

// 创建文件夹路径
export const PostCreatDocumentTree = (data: postCreateDocumentTreeForm) => request.post<Common<any>>(AllFilesApi.PostCreatDocumentTree, data);

// 查询文件夹关系接口
export const GetDocumentTree = () => request.get<Common<any>>(AllFilesApi.GetDocumentTree);

// 修改文件夹名字和备注接口
export const PutUpdateDocumentTreeName = (data: putUpdateDocumentTreeName) => request.put<Common<any>>(AllFilesApi.PutUpdateDocumentTreeName, data);

// 删除文件夹接口
export const DeleteDocumentTree = (id: number | null) => request.delete<Common<any>>(`${AllFilesApi.DeleteDocumentTree}?id=${id}`);

// 删除指定文件
export const DeleteFileById = (id: number | null) => request.delete<Common<any>>(`${AllFilesApi.DeleteFileById}?id=${id}`);

// 树形结构查询文件列表接口
export const GetDocumentTreeFiles = (id: number | null) => request.get<Common<any>>(`${AllFilesApi.GetDocumentTreeFiles}?id=${id}`);

// 指定文件夹上传文件接口
export const PostUploadDocumentTreeFile = (data: postUploadDocumentTreeFile) => request.post<Common<any>>(AllFilesApi.PostUploadDocumentTreeFile,data);
